{extend name="inherit/form" /}

{block name="title"}编辑banner图{/block}

{block name="form"}
<style>
    .layui-form-item .layui-input-inline {
        width: 350px;
    }
</style>
{/block}

{block name="content"}
<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin"
    style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline">
            <input type="text" name="img" value="{$data.img}" lay-verify="required" lay-verType="tips"
                placeholder="请上传图片" autocomplete="off" class="layui-input">
        </div>
        <button style="float: left;" type="button" class="layui-btn upload">上传</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">链接</label>
        <div class="layui-input-inline">
            <input type="text" name="url" value="{$data.url}" lay-verify="required" lay-verType="tips"
                placeholder="请输入跳转链接" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="number" name="sort" value="{$data.sort}" lay-verify="required" lay-verType="tips"
                placeholder="请输入排序值, 值越大越靠前" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" lay-filter="sex">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="显示" {$data.status==1 ? 'checked' : '' }>
            <input type="radio" name="status" value="0" title="隐藏" {$data.status==0 ? 'checked' : '' }>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" value="{$data.id}">
        <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
    </div>
</div>
{/block}

{block name="foot"}
<script src="__admin__/xm-select/xm-select.js"></script>

<script>
    layui.config({
        base: '__layuiadmin__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function () {
        var $ = layui.$
            , upload = layui.upload
            , form = layui.form;

        upload.render({
            elem: '.upload'
            , url: "{:u('upload/image')}"
            , accept: 'images'
            , method: 'get'
            , acceptMime: 'image/*'
            , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            }
            , done: function (res) {
                console.log(res)
                layer.close(layer.index);
                layer.msg(res.msg, {
                    time: 1500
                })
                $(this.item).prev("div").children("input").val(res.url)
            }
        });
    })
</script>
{/block}